Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

73
Views
javascript [1,2,3,4] becomes 12, 23, 34

i like to ask for advise how to let this array [1,2,3,4] to become 12, 23, 34?

this initial is a number 1234, i split them

let sum
sum = String(this.numbers).split("").map(Number);
console.log('numbers set1', sum)

so from here it becomes [1,2,3,4]

how can i join/combine/concat then to become 12, 23, 34 respectively?

thank you very much for Hello World's guidance

thank you

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You may want to write simple algorithm to get pairs of those numbers. Try to traverse the string/list and insert the new values into another list.

Sudo code can be something like: let's say you have arr with numbers [1,2,3,4]

for i = 1 to N:
 string sum = arr[i-1]+arr[i];
 list.push(sum)
about 4 years ago · Juan Pablo Isaza Report

0

You can easily achieve the result using split, map, and filter

const num = 1234;
const result = String(num)
  .split("")
  .map((n, i, src) => (src.length !== i + 1 ? `${n}${src[i + 1]}` : null))
  .filter(Boolean)
  .map(Number);

console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

var arr=[1,2,3,4];
    var list=[];
    for(i=1;i<arr.length;i++){
        let sum = parseInt(arr[i-1].toString()+arr[i].toString())
        list.push(sum)
    }
console.log(list);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!